#pragma once
#include "Mapper.h"
#include "NesCartridge.h"
#include <assert.h>
class Mapper066 :public Mapper
{
public:
	Mapper066(Famicom *fc):Mapper(fc)
			{

			}

	void OnReset()override {
		FormatBank(BANKSIZE_16KB, BANKSIZE_8KB);
		SetCPUBank_16KB(0, 0);
		SetCPUBank_16KB(1,mROM->prg16kbCount - 1);
		SetPPUBank_8KB(0);
	}
	virtual void Write6000(uint16_t address, uint8_t data) override
	{
		//LoadPrgBank_32KB(0,(data & 0xF0) >> 4);
		uint8_t prgbank = (data & 0xF0) >> 4 << 1;
		SetCPUBank_16KB(0, prgbank);
		SetCPUBank_16KB(1, prgbank + 1);
		SetPPUBank_8KB(data & 0x0F);
	}

	virtual void WriteViaCPU(uint16_t address, uint8_t data) override {
		uint8_t prgbank = (data & 0xF0) >> 4 << 1;
		SetCPUBank_16KB(0, prgbank);
		SetCPUBank_16KB(1, prgbank + 1);
		SetPPUBank_8KB(data & 0x0F);
	};
};
